<template>
  <div class="home">
    <el-container>
      <el-header>
        <i class="el-icon-user"></i>
        <span> 姓名:{{ name }} 工号:{{ eid }} </span>
        <router-link to="/" class="s1" style="position: absolute; right: 50px" @click.native="clear()"
          >退出</router-link
        >
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            v-if="op == '99'"
          >
            <el-menu-item index="1">
              <router-link to="/home/staff" slot="title">
                <i class="el-icon-s-custom"></i>
                <span>员工管理</span>
              </router-link>
            </el-menu-item>
            <el-menu-item index="2">
              <router-link to="/home/goods" slot="title">
                <i class="el-icon-s-goods"></i>
                <span>商品管理</span>
              </router-link>
            </el-menu-item>
            <el-menu-item index="3">
              <router-link to="/home/sell" slot="title">
                <i class="el-icon-s-marketing"></i>
                <span>销售管理</span>
              </router-link>
            </el-menu-item>
            <el-menu-item index="4">
              <router-link to="/home/promotion" slot="title">
                <i class="el-icon-shopping-bag-1"></i>
                <span>促销活动</span>
              </router-link>
            </el-menu-item>
          </el-menu>
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            v-else
          >
            <el-menu-item index="1">
              <router-link to="/home/loading" slot="title">
                <i class="el-icon-sell"></i>
                <span>上货</span>
              </router-link>
            </el-menu-item>
            <el-menu-item index="2">
              <router-link to="/home/cash" slot="title">
                <i class="el-icon-shopping-cart-2"></i>
                <span>收银</span>
              </router-link>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import stroe from "../store/index";
export default {
  data() {
    return {
      name: stroe.state.user.name,
      eid: stroe.state.user.eid,
      op: stroe.state.user.op,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    clear(){
      stroe.state.user={}
    }
  },
};
</script>
<style scoped lang='less'>
.el-container,
.home {
  height: 100%;
  // overflow:hidden
}
.el-header {
  background: #409eff;
  color: #fff;
}
.el-aside {
  background: #333;
  color: #fff;
  line-height: 200px;
}
.el-main {
  background: #fff;
}
.el-menu {
  height: 100%;
  background: #333;
}
.el-menu a {
  text-decoration: none;
  color: #999;
}
.el-menu-item.is-active,
.router-link-exact-active span,
.el-menu-item .router-link-exact-active i {
  color: #fff;
}
.s1 {
  color: #fff;
  text-decoration: none;
}
.el-header i,
.s1,
.el-header span {
  padding: 20px 0;
}
</style>
